﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Antioch.Base
{
    [Jemgine.Engine.Category("Antioch System"), Jemgine.Engine.Node]
    public class ChangeMap : Jemgine.Data.ScriptNode
    {
        public String MapName { get; set; }

        [Microsoft.Xna.Framework.Content.ContentSerializer(Optional = true)]
        public String NodeToFire { get; set; }

        public ChangeMap()
        {
            AddInput("Fire", null);
        }

        public override void FireTerminal(int InputID, Jemgine.Data.ScriptPayload Payload)
        {
            if (InputID == 0)
            {
                var GameState = Sim.GetModule<GameStateModule>();
                if (GameState == null) throw new InvalidOperationException(); //TODO : Exception for missing module.

                GameState.BeginChangeMap(MapName, NodeToFire);
            }
        }
    }
}
